package routes

import (
	"github.com/gin-gonic/gin"
	"library-system/controllers"
	"library-system/middlewares"
)

func RegisterUserRoutes(publicRouter *gin.Engine) {
	userController := controllers.UserController{}

	// 用户组路由
	userGroup := publicRouter.Group("/users")
	{
		userGroup.POST("/register", userController.Register)
		userGroup.POST("/login", userController.Login)

		// 需要管理员权限
		adminGroup := userGroup.Group("")
		//adminGroup.Use(middlewares.AdminAuth())
		adminGroup.Use(middlewares.JWTAuth(), middlewares.AdminAuth())
		{
			adminGroup.GET("/list", userController.ListUsers)
			adminGroup.PUT("/:id", userController.UpdateUser)
			adminGroup.DELETE("/:id", userController.DeleteUser)
		}
	}
}
